//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

#ifndef BASE_H_
#define BASE_H_

#include "Definitions.h"

using namespace std;

class Base : public cSimpleModule
{
private:
    int numOfFrames;
    volatile int ARQ_Block_Size;        //(bytes)
    int PDU_Size;                       //(blocks)
    volatile int frameSize;
    int numOfBlocks;

    volatile int curFrameCC;
    volatile int curFrameCS;
    volatile int curFramePIC;
    volatile int curFramePIS;
    volatile int curFramePII;
    volatile int curFrameP3C;
    volatile int curFrameP3S;
    stack<int> stackConventional;           //stack for the blocks of Conventional Selective
    stack<int> stackProposalI;              //stack for the blocks of Proposal I Selective
    stack<int> stackProposalII;
    stack<int> stackProposal3C;
    stack<int> stackProposal3S;

protected:
    virtual void initialize();
    virtual void handleMessage(cMessage *msg);

    virtual void handleConvC(ARQ_pck *msg);

    virtual void initConvSel();
    virtual void sendConvSel(Data *msg);
    virtual void handleConvSel(ARQ_pck *msg);

    virtual void handlePrIC(ARQ_pck *msg);

    virtual void initPrISel();
    virtual void sendPrISel(Data *msg);
    virtual void handlePrISel(ARQ_pck *msg);

    virtual void initPrII();
    virtual void sendPrII(Data *msg);
    virtual void handlePrII(ARQ_pck *msg);

    virtual void initPr3C();
    virtual void sendPr3C(Data *msg);
    virtual void handlePr3C(ARQ_pck *msg);

    virtual void initPr3S();
    virtual void sendPr3S(Data *msg);
    virtual void handlePr3S(ARQ_pck *msg);

//    virtual void initPrIIISel(bool blerUp);
    virtual void fillStack(int type);
    virtual void upARQSize();
    virtual void printMessage(Data *msg, int frame, string dest);
    virtual void printMessage(int block, int frame, string dest);
};

#endif /* BASE_H_ */
